package com.example.myapplication;

import android.graphics.Color;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.myapplication.Util.SizeChangeUtil;

import org.w3c.dom.Text;

public class MainActivity2 extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        TextView tv2 = findViewById(R.id.tv2);
//        获取layout的布局参数，包括宽高
        ViewGroup.LayoutParams layoutParams = tv2.getLayoutParams();
//        修改布局参数的宽度数值，默认是px为单位，需要将其改为dp为单位
        layoutParams.width= SizeChangeUtil.dp2px(this,300);
        tv2.setLayoutParams(layoutParams);
    }
}
